<%--
  Created by IntelliJ IDEA.
  User: 28633
  Date: 2021/1/21
  Time: 19:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--导入配置页面--%>
<%@ include file="basePath.jsp"%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>忘记密码</title>
    <link type="text/css" rel="stylesheet" href="${basePath}/static/reception/css/password.css" />
    <script type="text/javascript" src="${basePath}/static/reception/js/jquery-1.11.1.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var height=$(document).height();
            $('.main').css('height',height);
        })
    </script>
</head>
<body>

<div class="main">
    <div class="main0">
        <div class="formBox">
            <form method="post">
            <h3>登录密码重置</h3>
            <ul>
                <li class="mainCol firLi">&gt;身份验证</li>
                <li class="mainCol">&gt;登录密码重置</li>
                <li class="lastLi">&gt;重置完成</li>
            </ul>
            <img src="${basePath}/static/reception/images/line2.png" />

            <div class="itembox itembox_2">
                <label>用户名&nbsp;:</label>
                <input type="text" id="username" placeholder="请输入手机号对应的用户名">
            </div>
                <span id="dui" style="display:none; color: red;" >
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            用户名不符合要求
                </span>
                <span id="dui1" style="display:none; color: red;" >
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            用户名已存在
                </span>
            <div class="itembox itembox_2">
                <label>登录密码&nbsp;:</label>
                <input type="password" id="password" placeholder="请输入新登录密码" onblur="checkPassword()"></span>
            </div>
            <span id="cuo" style="display:none; color: red">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    密码不符合要求
            </span>
            <div class="itembox itembox_2">
                <label>确认密码&nbsp;:</label>
                <input type="password" id="ConfirmPassword" placeholder="请再次输入新密码" onblur="checkPwd()"></span>
            </div>
            <span  id="cuo1" style="display:none; color: red;">
            &nbsp;        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    密码不一致，请重新输入
                    </span>
            </form>
            <div class="btnBox">
                <input type="button" onclick="next()" value="下一步"></button>
            </div>
        </div>
    </div>
</div>

<div class="footer">
    <div class="footer0">
        <div class="footer_l">使用条款 | 隐私保护</div>
        <div class="footer_r">© 2015 （杭州）金融信息服务有限公司    杭ICP备0000000号</div>
    </div>
</div>
<script type="text/javascript">

    var regPassword = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/;
    var regUsername = /^\w{5,15}$/;
    /**
     * 核对密码
     */
    function checkPassword() {
        let password = document.getElementById("password").value;
        let cuo = document.getElementById("cuo");
        if (!regPassword.test(password)) {
            cuo.style.display = "block";
        } else {
            cuo.style.display = "none";
        }
    }

    /**
     * 确定密码
     */
    function checkPwd() {
        let regPassword = document.getElementById("ConfirmPassword").value;
        let password = document.getElementById("password").value;
        let cuo1 = document.getElementById("cuo1");
        if (password!=regPassword) {
            cuo1.style.display = "block";
        } else {
            cuo1.style.display = "none";
        }
    }

    /**
     * 核对用户名是否存在
     */
    function checkUsername() {
        let username = document.getElementById("username").value;
        let dui = document.getElementById("dui");
        let dui1 = document.getElementById("dui1");
        if (!regUsername.test(username)){
            dui.style.display = "block";
        } else {
            dui.style.display = "none";
        }


    function next() {
        let phone = document.getElementById('password').value;
        let username = document.getElementById('username').value;
            $.post("${basePath}lt_web/updatePwd",{"password":password},{"username":username},function (data) {
                // 如果传过来的数据不为空
                console.log(data);
                if (data != null) {
                    if (data == 1){
                        alert("符合要求");
                        window.location.href="${basePath}lt_web/lt_topwd3";
                    }else {
                        alert("请检查你的用户名是否正确！！！");
                    }
                }
            },'json');
    }
    }
</script>
</body>
</html>
